/**
 * Created with IntelliJ IDEA.
 * Description:
 * User: ${USER}
 * Date: ${YEAR}-${MONTH}-${DAY}
 * Time: ${TIME}
 */
public class Main {
    public static void main(String[] args) {
        System.out.println("Hello world!");
    }
}
class Solution {
    public int evalRPN(String[] tokens) {
        int ret = -1,num1 = 0,num2 = 0;
        Stack<Integer> stack1 = new Stack<>();
        for (int i = 0;i < tokens.length;i++) {
            switch(tokens[i]){
                case "+":
                    num1 = stack1.pop();
                    num2 = stack1.pop();
                    ret = num2 + num1;
                    stack1.push(ret);
                    break;
                case "-":
                    num1 = stack1.pop();
                    num2 = stack1.pop();
                    ret = num2 - num1;
                    stack1.push(ret);
                    break;
                case "*":
                    num1 = stack1.pop();
                    num2 = stack1.pop();
                    ret = num2 * num1;
                    stack1.push(ret);
                    break;
                case "/":
                    num1 = stack1.pop();
                    num2 = stack1.pop();
                    ret = num2 / num1;
                    stack1.push(ret);
                    break;
                default:
                    stack1.push(Integer.parseInt(tokens[i]));
            }
        }
        return stack1.peek();

    }
}